package com.jiuyi.controller;

import com.jiuyi.common.R;
import com.jiuyi.dto.UserPhoneCodeDto;
import com.jiuyi.entity.User;
import com.jiuyi.service.Impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * DATA: 2022/10/22
 * Author: 晨夕
 */

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserServiceImpl userServiceImpl;

    /**
     * 获取短信
     */
    @PostMapping("/sendMsg")
    public R sendMsg(@RequestBody UserPhoneCodeDto userPhoneCodeDto, HttpServletRequest request){
        return userServiceImpl.sendMsg(userPhoneCodeDto,request);
    }
    /**
     * 登录
     */
    @PostMapping("/login")
    public R login(@RequestBody UserPhoneCodeDto userPhoneCodeDto, HttpServletRequest request){
        return userServiceImpl.login(userPhoneCodeDto,request);
    }
    /**
     * 退出登录
     */
    @PostMapping("/loginout")
    public R logout(HttpServletRequest request){
        return userServiceImpl.logout(request);
    }
}
